<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection">
    <title>我的团队</title>
    <link rel="stylesheet" href="../style/base.css">
    <link rel="stylesheet" href="../style/layout.css">
    <script src="https://cdn.bootcss.com/jquery/3.2.0/jquery.min.js"></script>
    <script src="../js/paramsTool.js"></script>
    <script src="../../js/layer.js"></script>
</head>
<style type="text/css">
    .top{width:100%; height:60px; line-height:60px; text-align:center; background:#36a2f9; color:#fff; font-size:18px;}
    .top #extract{position: absolute; right: 5px;top: 0px;font-size:14px; height: 60px; line-height: 60px; width: 100px;}
    .top #cashList{position: absolute; left: 5px;top: 0px;font-size:14px; height: 60px; line-height: 60px; width: 100px;}
    .listnum1{background:#f7f7f7;width:100%;height:30px; line-height:30px;border-top:1px solid #ddd;border-bottom:1px solid #ddd;}
    .listnum1 .left{float:left;width:30%;color:#898989;margin-left:5%;font-size:14px;}
    .listnum1 .right{float:left;width:50%;color:#898989;font-size:14px;}
    /***战友团明细***/
    .infoline_bands{width:100%;height:58px;padding:1px 0;border-bottom: solid #f0efef 1px; display:block; overflow:hidden;background:#fff; font-weight:100;}
    .infoline_bands .infopic{width:20%; float:left;line-height:58px;  padding: 0 5px;}
    .infoline_bands .infopic img{width:40px; height:40px;border-radius:100%; border:1px solid #CCC;margin:3px 0 0 0px;}
    .infoline_bands .infotxt{float:left;width: 40%; text-align:left; margin-top: 7px; line-height: 1.5; padding: 0 5px; }
    .infoline_bands .infotxt .name{padding-top:5px;text-align:left; font-weight:bold; font-size:12px;float:left;overflow:hidden; color:#000;}
    .infoline_bands .infotxt .time{padding:0px 2px 0 0; clear:both; min-height:18px;text-align:left; font-size:10px; float:left;display:block; font-weight:bold; overflow:hidden;}
    .infoline_bands .infori{width: 25%;float: left;text-align: right;}
    .infoline_bands .infori >div{padding-top: 7px;}
    .sort{width:100%; text-align:center; font-size:13px; color:#333; height:40px; line-height:40px;border-bottom:0px solid #ddd; background:#f7f7f7;}
    .sort li{width:50%;float:left;}
    .sort .sel{color:#36a2f9; font-weight:bold; border-bottom:1px solid#36a2f9;}
    .marLeft{margin:10px;}
    .marLeft label{color:#36a2f9}
    .btnClass{margin: 15px auto;width: 90%;height: 35px;line-height: 35px;text-align: center;background-color: #36a2f9;font-size: 17px;color: #FFF;border-radius: 5px;}

</style>
<script>
    var host = window.location.origin;
    var params = queryString();
    var disOpenid,ref = 1;
    if(params.disOpenid){
        disOpenid = params.disOpenid
    }else {
        disOpenid = getCookie('disOpenid');
    }

    if(!disOpenid){
        getDisWxCode();
    }

    //dataNum
    var vipTotal = 0;
    var todUser = 0;
    var vipUser = 0;

    $(function () {
        getData(ref);

        $(".sort li").click(function() {

            $(this).siblings('li').removeClass('sel');  // 删除其他兄弟元素的样式
            $(this).addClass('sel');                    // 添加当前元素的样式

            ref = parseInt($(".sel").data('postid'));
            if(ref){
                $('#topName').html('直推总人数: ');
            }else {
                $('#topName').html('隔代总人数: ');
            }

            $("#band").empty();
            vipTotal = 0;
            todUser = 0;
            vipUser = 0;
            getData(ref);
        });
    });

    function getData(ref){

        var layInd = layer.open({
            type: 2,
            content:'加载中...',
            success : function () {
                $.ajax({
                    url: host+ '/getDisRefereeInfo',
                    type: "get",
                    dataType:'json',
                    async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                    cache:false,
                    headers: {"content-type":"application/json","disopenid":disOpenid,"ref":ref},
                    success:function(data){
                        if(data.code){
                            layer.close(layInd);        //关闭遮罩
                            alert('error:'+data.info);
                        }else {
                            var lists = data.refInfo;
                            $('#total').html(lists.length);
                            for(var i = 0;i<lists.length;i++){
                                if(new Date().toDateString() == new Date(lists[i].regDate).toDateString()){
                                    todUser++;
                                    if(lists[i].vip) vipUser++;
                                }
                                var infoBan=$("<div></div>").addClass('infoline_bands');
                                var infopic=$("<div></div>").addClass('infopic').appendTo(infoBan);
                                var imgHead;
                                if(lists[i].coin){
                                    imgHead = $("<div style='color: #36a2f9; font-size: 14px; font-weight: 600;'>金币: "+lists[i].coin/100+"</div>").appendTo(infopic);
                                }
                                imgHead = $("<div>金币: 0</div>").appendTo(infopic);
                                var infotxt = $("<div></div>").addClass('infotxt').appendTo(infoBan);
                                var name = $("<div>ID:"+lists[i].uid+"</div>").addClass('name').appendTo(infotxt);
                                var time = $("<div>"+dateFormate(lists[i].regDate)+"</div>").addClass('time').appendTo(infotxt);
                                var infori = $("<div></div>").addClass('infori').appendTo(infoBan);
                                if(parseInt(lists[i].vip)){
                                    vipTotal++;
                                    $("<div style='color: #36a2f9; font-size: 14px; font-weight: 600;'>VIP</div>").appendTo(infori);
                                }

                                $("<div>积分:"+lists[i].poin+"</div>").appendTo(infori);
                                infoBan.appendTo($('#band'));
                            }
                            $('#vipTotal').html(vipTotal);
                            $('#todUser').html(todUser);
                            $('#vipUser').html(vipUser);
                            layer.close(layInd);        //关闭遮罩
                        }
                    },
                    error:function() {
                        layer.close(layInd);        //关闭遮罩
                        alert('获取数据失败,请重试!');
                    }

                });

            }
        });
    }

</script>
<body>
<!--顶部bar-->
<div class="top">
    <label id="topName">直推总人数: </label><label id="total" style="font-weight: 600">0</label>
</div>
<!--顶部bar结束-->
<div class="listnum1">
    <div class="left">
       VIP总数:<label id="vipTotal" style="color:#36a2f9;font-weight: 600">0</label>
    </div>
    <div class="right">
       今日新增:<label id="todUser" style="color:#36a2f9;font-weight: 600">0</label>  新增VIP:<label id="vipUser" style="color: #36a2f9;font-weight: 600"></label>
    </div>
    <div class="clear"></div>
    <ul class="sort">
        <li class=" sel" data-postid="1" >直推列表</li>
        <li data-postid="0">隔代列表</li>
    </ul>

</div>
<div id="band">

</div>
</body>
</html>